/*
 *  FILE: 
 *  	spp.h
 *
 *  DESCRIPTION:
 *      Official Implementation of the Simple Peer Protocol.
 *
 *  FUNCTIONS:
 *      ...
 *
 *
 * Copyright (c) 2006 Karlan Thomas Mitchell<karlanmitchell@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *         This product includes software developed by
           Karlan Thomas Mitchell<karlanmitchell@comcast.net>
 * 4. Neither Karlan Thomas Mitchell nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY KARLAN THOMAS MITCHELL AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __SIMPLE_PEER_PROTOCOL_
#define __SIMPLE_PEER_PROTOCOL_
#include "portable_socket.h"
#include "mini_db.h"


/*Struct for storing Simple Peer Protocol Packets*/
#define st_spp_packet st_mdb
#define spp_packet_get   mdb_get
#define spp_packet_set   mdb_set

/*Holds data specific to client applicable actions*/
/*Struct for Client Simple Peer Protocol*/
struct st_spp_client {
	char password[100];
	};
/*Holds data specific to ultra/server applicable actions*/
/*Struct for Ultra Simple Peer Protocol*/
struct st_spp_ultra {
	char password[100];
	struct st_mdb user_list;
	};

/*Used to associate connections*/
/*Struct for Simple Peer Protocol*/
struct st_spp_ctx {
	char userid[100];
	char address[16];

	int rsp,fsp; /*File Service port, routing service port
                       Please set to 0 if not present!!!!*/

	struct st_spp_client client;
	struct st_spp_ultra  ultra;
	};

/*Get/Set passwords, password should be NULL to retrive current password*/
char * spp_ultra_pass(struct st_spp_ctx * spp_data, char * password);
char * spp_client_pass(struct st_spp_ctx * spp_data, char * password);

/*Get/Set userid, userid should be NULL to retrive current userid*/
char * spp_userid(struct st_spp_ctx * spp_data, char * userid);

/*Get/Set address, address should be NULL to retrive current IP address*/
char * spp_address(struct st_spp_ctx * spp_data, char * address);

/*Simple Peer Protocol/File Service Bind*/
int spp_fs_bind();
/*Simple Peer Protocol/Routing Service Bind*/
int spp_rs_bind();

int spp_readpacket(struct st_psocket * socket_data, struct st_spp_packet * protocol_data, long timeout);



#endif
